﻿<%@ Page Language="C#" AutoEventWireup="True"  EnableViewState="true" CodeBehind="Visa_infoForm.aspx.cs" Inherits="FS.Web.BLL.Visa_Base.Visa_infoForm" %>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>    
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/Validator/JValidator.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/artDialog.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/artDialog/iframeTools.source.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Fadd() {
            var trust = $("#trust_id").val();
            var countryid = $("#detail_city").val();
            var certtypeid = $("#detail_type").val();
            var customer = $("#detail_customer").val();
            var cardno = $("#detail_cardno").val();
            var cprice = $("#detail_begmoney").val();
            var infoid = $("#Hinfo").val();
            var supplyid = $("#detail_supply").val();
            var sprice = $("#HD_Sprice").val();
            var viewSupply = $("#HD_viewSupply").val();
            var detailid = $('#HDetailID').val();

            if (trust == "") {
                showTipsMsg("请选择委托方！", 2000, 5);                
                return false;
            }
            if (countryid == "") {
                showTipsMsg("请选择签证国家！", 2000, 5);                
                return false;
            }
            if (certtypeid == "") {
                showTipsMsg("请选择签证类型！", 2000, 5);               
                return false;
            }
            if (cprice == "" || cprice==0) {
                cprice = "0";
            }
            if (customer == "") {               
                showTipsMsg("请输入客户名称！", 2000, 5);
                return false;
            }

            var parm = "";
            if (viewSupply == "1") {
                if (supplyid == "") {
                    showTipsMsg("请选择供应商！", 2000, 5);
                    return false;
                }
                parm = 'action=InsertInfoDetailWithSupply&cityid=' + escape(countryid) + '&certtype=' + escape(certtypeid) +
                   '&cprice=' + escape(cprice) + '&infoid=' + escape(infoid) +
                   '&insert_user=' + escape(customer) + '&insert_cardno=' + escape(cardno) +
                   '&supplyid=' + escape(supplyid) + '&sprice=' + escape(sprice) + '&detailid=' + escape(detailid);
            }
            else {
                parm = 'action=InsertInfoDetail&cityid=' + escape(countryid) + '&certtype=' + escape(certtypeid) +
                   '&cprice=' + escape(cprice) + '&infoid=' + escape(infoid) +
                   '&insert_user=' + escape(customer) + '&insert_cardno=' + escape(cardno) + '&detailid=' + escape(detailid);
            }
            
            getAjax('info.ashx', parm, function (rs) {
                try {
                    if ( rs !="ok" ) {                       
                        showTipsMsg("<span style='color:red'>" + rs + "</span>", 4000, 5);
                        return false;
                    }
                } catch (e) {
                }
            });
        }
        function ChangeArea() {
            var cityarea = $("#detail_area").val();
            var parm = 'action=getcitybyarea&cityarea=' + escape(cityarea);
            getAjax('base.ashx', parm, function (rs) {
                try {                   
                    var json = eval("(" + rs + ")");
                    $("#detail_city").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到区域下的国家信息，请到【国家信息】窗口维护！", 2000, 5);
                    } else {                        
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_city").append("<option value='" + menu.CITY_ID +
                                "'>" + menu.CITY_NAME + "</option>");
                        }
                    }
                } catch (e) {
                }
            });
        }
        function ChangeCity() {
            var cityid = $("#detail_city").val();           

            var parm = 'action=getcerttype&cityid=' + escape(cityid);
            getAjax('base.ashx', parm, function (rs) {
                try {
                    var json = eval("(" + rs + ")");
                    $("#detail_type").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到签证国家下的签证类型，请到【签证国家】窗口维护！", 2000, 5);
                    } else {
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_type").append("<option value='" + menu.ID +
                                "'>" + menu.NAME + "</option>");
                        }
                        ChangeType();
                    }
                } catch (e) {
                }
            });
        }

        function ChangeType() {           
            var certtype = $("#detail_type").val();
            var cityid = $("#detail_city").val();
            var trusttype = $("#Hpricecode").val();  //委托方价格类型            

            if (trusttype == "") {
                showTipsMsg("请选择委托方或定义委托方类型！", 2000, 5);
                return false;
            }

            var parm = 'action=GetPriceFromCityCert&cityid=' + escape(cityid) + '&certtype=' + escape(certtype) + '&trusttype=' + escape(trusttype);
            getAjax('base.ashx', parm, function (rs) {
                try {
                    $("#detail_begmoney").val(rs);
                } catch (e) {
                }
            });

            var view = $("#HD_viewSupply").val();
            if (view == "1")
            {
                GetSupplyList();
            }
        }

        function GetSupplyList() {
            var certtype = $("#detail_type").val();
            var cityid = $("#detail_city").val();            

            var parm = 'action=GetSupplybycitycert&cityid=' + escape(cityid) + '&certtype=' + escape(certtype)
            getAjax('base.ashx', parm, function (rs) {
                try {
                    var json = eval("(" + rs + ")");
                    $("#detail_supply").empty();
                    var len = json.MENU.length;
                    if (len = 0) {
                        showTipsMsg("找不到签证国家下的签证类型，请到【签证国家】窗口维护！", 2000, 5);
                    } else {
                        for (var i = 0; i < json.MENU.length; i++) {
                            var menu = json.MENU[i];
                            $("#detail_supply").append("<option value='" + menu.SUPPLY_ID +
                                "'>" + menu.SUPPLYPRICE + "</option>");
                        }
                        ChangeSupply();
                    }
                } catch (e) {
                }
            });
        }
        
        function ChangeSupply() {
            var ls_txt = $("#detail_supply").find("option:selected").text();            
            var ls_price = ls_txt.split(":");
            $("#HD_Sprice").val(ls_price[1]);
        }

        function GetTrustInfo() {
            var trust = $("#trust_id").val();
            if (trust != "") {
                var parm = 'action=gettrustinfo&trust_id=' + escape(trust);
                getAjax('base.ashx', parm, function (rs) {
                    try {
                        if (rs != "") {
                            var tmp = rs.split("@");
                            $("#Ref_trusttype").val(tmp[0]);
                            //$("#Ref_pricetype").val(tmp[1]);
                            $("#info_contactnumber").val(tmp[2]);
                            $("#info_contactuser").val(tmp[3]);
                            $("#Hpricecode").val(tmp[4]);
                            $("#info_operation").val(tmp[5]);
                        } else {
                            showTipsMsg("找不到委托方信息，！", 2000, 5);
                        }
                    } catch (e) {
                    }
                });
            }
        }
        //删除
        function FDel() {
            var key = CheckboxValue();
            if (IsEditdata(key)) {  
                $("#HDetailID").val(key);
            }
        }

        //添加客户
        function AddTrust() {
            var url = "/BLL/Visa_Base/Base_TrustForm.aspx";
            top.openDialog(url, 'Menu_Form', '委托人列表信息 - 添加', 550, 230, 50, 50);
        }

        //添加供应商
        function AddSupply() {
            var url = "/BLL/Visa_Base/Base_SupplyForm.aspx";
            top.openDialog(url, 'Menu_Form', '供应商列表信息 - 添加', 550, 230, 50, 50);
        }

        //修改收款方式
        function ChangeMoneyFlag() {
            var moneyflag = $("#Ref_moneyflag").val();            
            var moneytype = "month";
            if (moneyflag == "yes") {
                moneytype = "money";
            }           
           
            $("#Ref_moneytype").get(0).value = moneytype;
        }
        function FEdit() {
            var key = CheckboxValue();
            if (IsEditdata(key)) {
                var tt = "<span class=\"icon-botton\"  style=\"background: url('/Themes/images/16/add.png') no-repeat scroll 0px 4px; \"> </span>更 新";
                $('#lbtadd').html(tt);
                $("#HDetailID").val(key);

                var parm = 'action=GetInfoDetail&detailid=' + escape(key);
                getAjax('/BLL/Visa_info/VisaInfo.ashx', parm, function (rs) {
                    try {
                        var V_JSON = rs;
                        var json = eval("(" + V_JSON + ")");
                        for (var i = 0; i < json.DETAIL.length; i++) {
                            var datas = json.DETAIL[i];

                            $("#detail_customer").val(datas.INFODETAIL_USER);
                            $("#detail_city").val(datas.CITY_ID);
                            ChangeCity();
                            $("#detail_type").val(datas.REF_CERTTYPE);
                            ChangeType();
                            $("#detail_begmoney").val(datas.INFODETAI_BEGPRICE);
                            $("#detail_cardno").val(datas.INFODETAIL_CARDNO);
                            $("#detail_userphone").val(datas.INFODETAIL_USERPHONE);
                            $("#detail_data").val(datas.DATA_INTEGRITY);

                            $("#detail_supply").val(datas.SUPPLY_ID);
                            $("#detail_remark").val(datas.INFODETAIL_REMARK);
                        }
                    } catch (e) {
                    }
                });
            }
        }

        function FClear() {
            $("#detail_customer").val("");
            $("#detail_city").val(0);
            $("#detail_type").empty;
            $("#detail_begmoney").val(0);
            $("#detail_cardno").val("");
            $("#detail_userphone").val("");
            $("#detail_data").val(0);
            $("#detail_supply").empty();
            $("#detail_remark").val("");

            clearstatus();
        }
        function clearstatus() {
            //清空编辑状态
            $('#HDetailID').val("")
            var tt = "<span class=\"icon-botton\"  style=\"background: url('/Themes/images/16/add.png') no-repeat scroll 0px 4px; \"> </span>添 加";
            $('#lbtadd').html(tt);
        }
    </script>       
</head>
<body>    
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <input id="Hinfo" type="hidden" runat="server"  />
    <input id="Hpricecode" type="hidden" runat="server"/>         
    <input id="HDetailID" type="hidden" runat="server"/> 
    <input id="HD_viewSupply" type="hidden" runat="server" value="0"/> 
    <input id="HD_Sprice" type="hidden" runat="server" value="0"/>
    <input id="HD_AddNo" type="hidden" runat="server" value="0"/>             
    <table border="0" cellpadding="0" cellspacing="0" class="frm">                
        <tr>
            <th>                
                <img alt="" src="/Themes/images/16/add.png" onclick="AddTrust()" border="0" style="vertical-align:middle;"
                id="img_trust" runat="server" />委托方 
            </th>
            <td>
                <select id="trust_id" runat="server" type="text" class="select" style="width: 116px" onchange="GetTrustInfo()" />                
            </td>
             <th>
                 业务员：
            </th>
            <td>
               <input id="info_operation" runat="server" type="text" class="txt"  style="width: 110px"  />
            </td>
            <th>
                收签时间：
            </th>
            <td>
               <input id="info_getdate" runat="server" type="text" class="txt" datacol="yes" err="收签时间"
                     style="width: 110px" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd' })" />
            </td>                  
            <th>
                 签证状态：</th>                   
            <td>
                <select id="Ref_infoflag" runat="server" disabled="disabled" type="text" class="select" style="width: 116px" />
            </td>                  
        </tr>        
        <tr>           
             <th>
                委托方类型：
            </th>
            <td>
                <input id="Ref_trusttype" runat="server" type="text" class="txt" disabled="disabled" style="width: 110px"  />               
            </td>
             <th>
                团号：
            </th>
            <td>
               <input id="info_TuanNo" runat="server" type="text" class="txt" style="width: 110px" />
            </td>
             <th>
                联系方式：
            </th>
            <td>
               <input id="info_contactnumber" runat="server" type="text" class="txt" style="width: 110px" />
            </td>
            <th>
                &nbsp;</th>                   
            <td>
                &nbsp;</td>             
        </tr>
        <tr>
           <th>
                备注：
            </th>
           <td colspan="7">
                <textarea id="info_remark" class="txtRemark" runat="server" style="width: 95%;height: 40px;"></textarea>
            </td>   
        </tr>
        <tr>
            <td colspan="8">
                <div class="btnbarcontetn">
                    <div>添加客户信息 </div>
                </div>
            </td>
        </tr>
        <tr>
            <th>
                客户姓名：
            </th>                    
            <td>
                <input id="detail_customer" runat="server" type="text" class="txt" style="width: 110px" onFocus="this.select()" />                        
            </td>
            <th >
                签证国家：</th>
            <td >
                <select id="detail_city" runat="server" type="text" class="select" style="width: 116px" onchange="ChangeCity()" />                                              
            </td>
            <th >
                签证类型：
            </th>
            <td >
                <select id="detail_type" runat="server" type="text" class="select" 
                    style="width: 116px" onchange="ChangeType()" />
            </td>
             <th>                        
                <div id="div_Price1" runat="server">签证费用：</div>
            </th>
            <td>
                <div id="div_Price2" runat="server">
                    <input id="detail_begmoney" runat="server" type="text" class="txt" style="width: 110px" />
                </div>
            </td>            
        </tr>
        <tr>
            <th>
               护照号：
            </th>
            <td>
                <input id="detail_cardno" runat="server" type="text" class="txt" style="width: 110px" />                        
            </td>
            <th>
               客人电话：
            </th>
            <td>
                <input id="detail_userphone" runat="server" type="text" class="txt" style="width: 110px" />                        
            </td>
            <th>
                资料齐全：
            </th>
            <td>
                <select id="detail_data" runat="server" class="select" style="width:116px">
                    <option value="1">齐全</option>
                    <option value="0">不全</option>
                </select>                        
            </td>
            <th>
                <div id="div_Supply1" runat="server">
                    <img alt="" src="/Themes/images/16/add.png" onclick="AddSupply()" border="0" 
                        style="vertical-align:middle;" id="img_supply" runat="server" />供应商：
                </div> 
            </th>
            <td > 
                <div id="div_Supply2" runat="server">                       
                    <select id="detail_supply" runat="server" type="text" class="select" 
                        style="width: 116px" onchange="ChangeSupply()" /> 
                </div>                       
            </td>
        </tr>
        <tr>
           <th>
                签证备注：
           </th>
           <td colspan="5">
               <input id="detail_remark" runat="server" type="text" class="txt" style="width:98%;" />               
           </td>
           <td colspan="2">
                <asp:LinkButton ID="lbtadd" runat="server" class="button green" OnClick="lbtadd_Click" OnClientClick="return Fadd()">
                    <span class="icon-botton"  style="background: url('/Themes/images/16/add.png') no-repeat scroll 0px 4px;">
                    </span>添 加
                </asp:LinkButton>
                <asp:LinkButton ID="lbtdel" runat="server" class="button green" OnClientClick="return FDel()" OnClick="lbtdel_Click" >
                    <span class="icon-botton"  style="background: url('/Themes/images/16/delete.png') no-repeat scroll 0px 4px;">
                    </span>删 除
                </asp:LinkButton>
                <asp:LinkButton ID="lbtedit" runat="server" class="button green" OnClientClick="return FEdit()">
                    <span class="icon-botton"  style="background: url('/Themes/images/16/edit.png') no-repeat scroll 0px 4px;">
                    </span>编 辑
                </asp:LinkButton>
                <asp:LinkButton ID="lbtclear" runat="server" class="button green" OnClientClick="return FClear()">
                    <span class="icon-botton"  style="background: url('/Themes/images/16/redo.png') no-repeat scroll 0px 4px;">
                    </span>重 填
                </asp:LinkButton>
           </td> 
        </tr>
        </table>
                  
        <div id ="detailsub1" style="height:190px; width:98%; overflow:auto; ">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" 
                ChildrenAsTriggers="False">
            <ContentTemplate >
            <table id="tabledd" class="example" >
                <thead>
                    <tr>
                        <td style="width: 20px; text-align: left;">
                            <label id="checkAllOff" onclick="CheckAllLine()" title="全选">
                                &nbsp;</label>
                        </td>                            
                        <td style="width: 30px; text-align: center;">序号</td>
                        <td style="width: 80px; text-align: center;">客户姓名</td>
                        <td style="width: 80px; text-align: center;">签证国家</td>
                        <td style="width: 80px; text-align: center;">签证类型</td>
                        <td style="width: 60px; text-align: center;">签证费用</td>
                        <td style="width: 70px; text-align: center;">护照号</td>
                        <td style="width: 70px; text-align: center;">客人电话</td>
                        <td style="width: 40px; text-align: center;">资料</td>
                        <td style="width: 80px; text-align: center;">供应商</td>
                        <td>签证备注</td>
                    </tr>
                </thead>
                <tbody> 
                    <asp:Repeater ID="rp_Item" runat="server">
                    <ItemTemplate>
                        <tr>
                            <td style="width: 20px; text-align: left;">
                                <input type="checkbox" value="<%#Eval("infodetail_id")%>" name="checkbox" />
                            </td>
                            <td style="width: 30px; text-align: center;">
                                <%#Eval("id")%>
                            </td>
                            <td style="width: 80px;">
                                <%#Eval("InfoDetail_user")%>
                            </td>                            
                            <td style="width: 80px;">
                                <%#Eval("city_name")%>
                            </td> 
                            <td style="width: 80px;">
                                <%#Eval("property_value")%>
                            </td>
                            <td style="width: 60px;">
                                <%#Eval("InfoDetai_BegPrice")%>       
                            </td>
                            <td style="width: 70px;">
                                <%#Eval("InfoDetail_cardno")%>
                            </td>
                            <td style="width: 70px;">
                                <%#Eval("InfoDetail_userphone")%>
                            </td>
                            <td style="width: 40px;">
                                <%#Eval("dataname")%>
                            </td>
                            <td style="width: 80px;">
                                <%#Eval("Supply_Name")%>
                            </td>
                            <td>
                                <%#Eval("InfoDetail_remark")%>
                            </td>                         
                        </tr>                                
                    </ItemTemplate>
                    <FooterTemplate>
                        <% if (rp_Item != null)
                            {
                                if (rp_Item.Items.Count == 0)
                                {
                                    Response.Write("<tr><td colspan='7' style='color:red;text-align:center'>没有找到您要的相关数据！</td></tr>");
                                }
                            } %>
                    </FooterTemplate>
                </asp:Repeater>                               
                </tbody>
            </table>
            </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="lbtadd" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbtdel" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbtedit" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbtclear" EventName="Click" />
                </Triggers>
        </asp:UpdatePanel> 
        </div>
        <div id ="detailsub2">
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" 
                ChildrenAsTriggers="False">
            <ContentTemplate > 
                <table id="detailend" border="0" cellpadding="0" cellspacing="0" class="frm">
        <tr>
            <th>
                人数：
            </th>
            <td>               
                <input id="info_outpeople" runat="server" type="text" disabled="disabled" class="txt" datacol="yes" err="人数"
                    checkexpession="Num" style="width: 110px" value="0" />
            </td>
                <th>
                签证费用：
            </th>
            <td>
                <input id="info_outmoney" runat="server" type="text" disabled="disabled" class="txt" datacol="yes" err="取件费用"
                    checkexpession="DoubleOrNull" style="width: 110px" value="0" />
            </td>
                <th>
                发票信息：
            </th>
            <td>
                <input id="Info_fapiao" runat="server" type="text" class="txt" datacol="yes" style="width: 110px" />
            </td>
            <th>
                发票金额：
            </th>
            <td>
                <input id="info_moneyfapiao" runat="server" type="text" class="txt" datacol="yes" err="发票金额"
                    checkexpession="DoubleOrNull" style="width: 110px" value="0" />               
            </td>
        </tr>
        <tr>
            <th>
                取件类型：
            </th>
            <td>               
                <select id="Ref_postby" runat="server" type="text" class="select"  style="width: 116px"></select>                 
                </td>
                <th>
                取件费用：
            </th>
            <td>
                <input id="Ref_postmoney" runat="server" type="text" class="txt" datacol="yes" err="取件费用"
                    checkexpession="DoubleOrNull" style="width: 110px" value="0" />
            </td>
            <th>
                收款方式：
            </th>
            <td>
                <select id="Ref_moneytype" runat="server" type="text" class="select"  style="width: 116px" ></select>                
            </td>
            <th>
                收款情况：
            </th>
            <td>
                <select id="Ref_moneyflag" runat="server" type="text" class="select"  style="width: 116px" onchange="ChangeMoneyFlag()">   
                </select>            
            </td>
        </tr>
        <tr>
            <th>
                应收费用：
            </th>
            <td>
                <input id="info_moneyin" runat="server" type="text" class="txt" datacol="yes" err="应收金额"
                    checkexpession="DoubleOrNull" style="width: 110px" />
            </td>
            <th>
                <div id="price3" runat="server">应付金额：</div> 
            </th>
            <td>
                <div id="price4" runat="server">
                <input id="info_moneyout" runat="server" type="text" class="txt" datacol="yes" err="应付金额"
                    checkexpession="DoubleOrNull" style="width: 110px" />
                </div> 
            </td>
            <th>&nbsp;</th>
            <td>&nbsp;</td>
            <th>&nbsp;</th>
            <td>&nbsp;</td>     
        </tr>
    </table>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="lbtadd" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="lbtdel" EventName="Click" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
    <div class="frmbottom">
        <asp:LinkButton ID="SaveAdd" runat="server" class="l-btn" OnClientClick="return CheckDataValid('#form1');"
            OnClick="SaveAdd_Click"><span class="l-btn-left">
            <img src="/Themes/Images/save.png" alt="" />新 增</span>
        </asp:LinkButton>
        <asp:LinkButton ID="Save" runat="server" class="l-btn" OnClientClick="return CheckDataValid('#form1');"
            OnClick="Save_Click"><span class="l-btn-left">
            <img src="/Themes/Images/save.png" alt="" />保 存</span>
        </asp:LinkButton>
        <a class="l-btn" href="javascript:void(0)" onclick="javascript:history.go(-1);"><span class="l-btn-left">
            <img src="/Themes/Images/cancel.png" alt="" />关 闭</span></a>       
    </div>
    </form>
</body>
</html>